package com.changgou.goods.dao;

import com.changgou.pojo.Brand;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @Author gentleman Ma
 * @Date created in 2020/2/11
 * @description   继承了Mapper接口，就自动实现了增删改查的常用方法。
 * @Version 1.0
 */

public interface BrandMapper extends Mapper<Brand> {

    //@Select("SELECT * FROM tb_brand WHERE id in (SELECT brand_id FROM tb_category_brand WHERE category_id in (SELECT id FROM tb_category WHERE `name` =#{categoryName}))")
    @Select("SELECT tbb.* FROM tb_brand tbb JOIN tb_category_brand tcb ON tbb.id = tcb.brand_id JOIN tb_category tc ON tcb.category_id = tc.id WHERE tc.`name` = #{categoryName}")
    List<Brand> selectByCategoryName(@Param("categoryName") String categoryName);
}
